﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace Server
{
    public partial class SaveFileToDirectory : Form
    {
        public event SaveFileToDirectoryEventHandler OnSaveFileToDirectory = null;
        //private Thread t = null;
        public SaveFileToDirectory()
        {
            InitializeComponent();
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            //this.t = new Thread(new ThreadStart(ShowFolderBrowseDialog));
            //this.t.Start();
            if (this.folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                //if (this.t != null)
                //{
                //    this.t.Abort();
                //}
                this.tbxPath.Text = this.folderBrowserDialog1.SelectedPath;
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.OnSaveFileToDirectory != null)
            {
                this.OnSaveFileToDirectory(this, new SaveFileToDirectoryEventArgs(this.folderBrowserDialog1.SelectedPath));
            }
        }

        private void ShowFolderBrowseDialog()
        {
            if (this.folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                //if (this.t != null)
                //{
                //    this.t.Abort();
                //}
                this.tbxPath.Text = this.folderBrowserDialog1.SelectedPath;
            }
        }
    }
}
